"""联系人页面"""
from page.base_page import BasePage
from selenium.webdriver.common.by import By

class ContactPage(BasePage):

    url = '/crm5/index.php?m=contacts&a=index'

    #定位器
    # 新建联系人
    new_add_contact_locator = (By.CSS_SELECTOR, 'body > div.container > div.row > div:nth-child(1) > div > a > i')
    #断言文本，添加成功
    success_tips_locator = (By.CSS_SELECTOR, 'body > div.container > div.alert.alert-success')
    #查看
    contact_view_locator = (By.CSS_SELECTOR,'#form1 > table > tbody > tr:nth-child(1) > td:nth-child(10) > a:nth-child(1)')

    def click_btn_add(self):
        """点击新建联系人"""
        self.driver.find_element(*self.new_add_contact_locator).click()

    def success_tips_text(self):
        """获取添加成功文本"""
        return self.driver.find_element(*self.success_tips_locator).text

    def click_btn_view(self):
        """点击查看"""
        self.driver.find_element(*self.contact_view_locator).click()